package com.example.myapplication;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
public class oneLock extends Activity {
    private ComponentName mCN;
    private DevicePolicyManager mDPM;
    @Override
    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        this.mDPM = ((DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE));
        this.mCN = new ComponentName(getApplicationContext(), AdminReceiver.class);
        if (this.mDPM.isAdminActive(this.mCN))
        {
            this.mDPM.lockNow();
            finish();
            return;
        }
        activeManager();
        finish();
        return;
     }

    private void activeManager()
    {
        Intent localIntent = new Intent("android.app.action.ADD_DEVICE_ADMIN");
        localIntent.putExtra("android.app.extra.DEVICE_ADMIN", this.mCN);
        localIntent.putExtra("android.app.extra.ADD_EXPLANATION", "");
        startActivity(localIntent);
    }
}



